﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Business.Enums;
using mozhi.smarterp.Business.Purchases.Receipt;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Business.Controllers.Purchases
{
    [RemoteService]
    [Route("api/v1/purchase/receipts")]
    public class PurchaseReceiptController : BusinessController
    {
        private IPurchaseReceiptAppService _appService;

        public PurchaseReceiptController(IPurchaseReceiptAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<PurchaseReceiptDto> GetAsync(Guid id)
        {
            return await _appService.GetAsync(id);
        }

        [HttpGet]
        public async Task<PagedResultDto<PurchaseReceiptDto>> GetAsync(PagedAndSortedResultRequestDto filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<PurchaseReceiptDto> CreateAsync(PurchaseReceiptCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<PurchaseReceiptDto> UpdateAsync(PurchaseReceiptUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }

        [HttpPut]
        [Route("{id}/status/{status}")]
        public async Task UpdateStatusAsync(Guid id, DocumentStatusType status)
        {
            await _appService.UpdateStatusAsync(id, status);
        }
    }
}
